﻿using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.JDPostBoard.Entity
{
    [Table("Apply_Gift_Relation", "", "JDPB.ConnectionString")]
    public class Apply_Gift_Relation : Info
    {
        #region SQL column name consts
        public const string SQLCOL_ID = "ID";
        public const string SQLCOL_APPLYID = "ApplyID";
        public const string SQLCOL_GIFTID = "GiftID";
        public const string SQLCOL_GIFTNAME = "GiftName";
        public const string SQLCOL_GIFTPRICE = "GiftPrice";
        public const string SQLCOL_GIFTUNIT = "GiftUnit";
        public const string SQLCOL_GIFTCOUNT = "GiftCount";
        public const string SQLCOL_GIFTTOTAL = "GiftTotal";
        public const string SQLCOL_REMARK = "Remark";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public Apply_Gift_Relation() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public Apply_Gift_Relation(int ID)
        {
            this.ID = ID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            ID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ID]);
            ApplyID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_APPLYID]);
            GiftID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_GIFTID]);
            GiftName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_GIFTNAME]);
            GiftPrice = (double)ObjectType.DoubleTypeHelper.Read(row[SQLCOL_GIFTPRICE]);
            GiftUnit = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_GIFTUNIT]);
            GiftCount = (double)ObjectType.DoubleTypeHelper.Read(row[SQLCOL_GIFTCOUNT]);
            GiftTotal = (double)ObjectType.DoubleTypeHelper.Read(row[SQLCOL_GIFTTOTAL]);
            Remark = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_REMARK]);
        }

        #region Properties
        #region Property <int> ID
        [Property("ID", 4, SqlDbType.Int, true, true)]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private int _ID = int.MinValue;
        #endregion

        #region Property <Guid> ApplyID
        [Property("ApplyID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid ApplyID
        {
            get { return _ApplyID; }
            set { _ApplyID = value; }
        }
        private Guid _ApplyID = Guid.Empty;
        #endregion

        #region Property <Guid> GiftID
        [Property("GiftID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid GiftID
        {
            get { return _GiftID; }
            set { _GiftID = value; }
        }
        private Guid _GiftID = Guid.Empty;
        #endregion

        #region Property <string> GiftName
        [Property("GiftName", 100, SqlDbType.NVarChar, false, false)]
        public string GiftName
        {
            get { return _GiftName; }
            set { _GiftName = value; }
        }
        private string _GiftName = null;
        #endregion

        #region Property <double> GiftPrice
        [Property("GiftPrice", 8, SqlDbType.Float, false, false)]
        public double GiftPrice
        {
            get { return _GiftPrice; }
            set { _GiftPrice = value; }
        }
        private double _GiftPrice = double.NaN;
        #endregion

        #region Property <string> GiftUnit
        [Property("GiftUnit", 100, SqlDbType.NVarChar, false, false)]
        public string GiftUnit
        {
            get { return _GiftUnit; }
            set { _GiftUnit = value; }
        }
        private string _GiftUnit = null;
        #endregion

        #region Property <double> GiftCount
        [Property("GiftCount", 8, SqlDbType.Float, false, false)]
        public double GiftCount
        {
            get { return _GiftCount; }
            set { _GiftCount = value; }
        }
        private double _GiftCount = double.NaN;
        #endregion

        #region Property <double> GiftTotal
        [Property("GiftTotal", 8, SqlDbType.Float, false, false)]
        public double GiftTotal
        {
            get { return _GiftTotal; }
            set { _GiftTotal = value; }
        }
        private double _GiftTotal = double.NaN;
        #endregion

        #region Property <string> Remark
        [Property("Remark", 1000, SqlDbType.NVarChar, false, false)]
        public string Remark
        {
            get { return _Remark; }
            set { _Remark = value; }
        }
        private string _Remark = null;
        #endregion
        #endregion


        public bool LoadByIdentity(int ID)
        {
            return DataAccess.SelectByIdentity(this, Convert.ToInt64(ID));
        }


        public bool DeleteByIdentity()
        {
            return DataAccess.DeleteByIdentity(this);
        }
    }
}
